Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support client-only initialization and more #28

Merged
merged 30 commits into from
Dec 12, 2018

Conversation

flut1
Copy link
Contributor

@flut1 flut1 commented Dec 6, 2018

In this PR:

  • Add support for splitting init actions into a client-only and prepared functions
  • Create usage guide
  • Format with prettier
  • Add integration tests ( fixes Add integration tests #3 )
  • Update API docs with new client-only feature

New features should be backwards compatible.

Floris Bernard and others added 28 commits November 28, 2018 16:13
Add support to pass an object as initAction, specifying a part
that should run prepared and a part that should only be executed
on the client.

Update the existing spec to make sure unit test still pass
Create a IsomorphicTestEnvironment utility that can be used in
integration tests to simulate a component rendering on the
server first and then on the client. This can be used to
test more complex situations.

Create 2 sample integration tests using the new utility. This
file is named .test.js to distinguish from the unit tests, which
are named .spec.js

Create an ExtendableError utility to create custom error classes.
Use this to create a custom error type PrepareValidationError. This
can be used to assert that a prepare validation error has occured
in tests (as opposed to another type of error).

Add the babel-plugin-transform-builtin-extend plugin to make sure
we can extend the builtin Error correctly.
Allow to run the integration tests separately from the unit
tests for faster test development
Fix nested it testing blocks. They are not valid jest
Because initComponent is now called from both willMount and
didMount, we need to make sure that the initAction is only called
from one of these hooks
Add an update function to IsomorphicTestEnvironment. This will make
sure allow us to re-render the test renderer with new components.
Use the fixture component instead of rewriting a component every
time
Check that component has been prepared should not be done when
initAction === null (clientOnly init action)
Instead of writing the whole JSON for actions dispatched, use
snapshot testing. This improves readability in the unit test
files
All store test state is static, so we can move it to a fixture
file to save some space in the unit test files
Log a warning on redundant calls to prepareComponent() when the
component only has client-side initialization
Changed the server-side render in IsomorphicTestEnvironment to
react-dom/server renderToStaticMarkup(). This is to prevent
didMount hooks from being called.

Create integration test that includes both prepared and clientOnly
actions

Fixed wording in unit test description.
@ThaNarie ThaNarie requested review from ThaNarie and removed request for mediamonks-arjan December 6, 2018 13:31
@flut1 flut1 changed the base branch from master to develop December 6, 2018 13:37
flut1 added 2 commits December 7, 2018 12:38
Included the clientOnly change to withInitAction docs

Updated formatting and styling of the docs

Temporarily changed the theme to a forked version to fix a charset
issue
@flut1 flut1 merged commit 679b95f into develop Dec 12, 2018
@flut1 flut1 deleted the feature/support-clientonly-init branch December 12, 2018 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants